package com.coldchain.cys.api;

import com.coldchain.authclient.annotation.CheckUserToken;
import com.coldchain.common.feign.SystemConfigFeign;
import com.coldchain.common.resource.annotation.Resource;
import com.coldchain.cys.entity.CysChild;
import com.coldchain.cys.mapping.MappingUtils;
import com.coldchain.cys.page.CysCashLogQueryVo;
import com.coldchain.cys.service.*;
import com.fangliai.core.entitiy.SystemModelEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 财务管理页面
 * @author TianPeng
 *
 * 2018年9月5日
 */
@Controller
@CheckUserToken
@Resource(groupName="财务管理", sysMode = SystemModelEnum.USER)
@ApiIgnore
public class FinanceController {
	
	@Autowired
	private	ICysAccountService cysAccountService ; 
	
	@Autowired
	private ICysService cysService ;
	
	@Autowired
	private ICysCashLogService cysCashLogService ;
	
//	@Autowired
//	private BizDispatchingOrderFeign bizDispatchingOrderFeign ;
	
	@Autowired
	private ICarService carService ;
	
	@Autowired
	private ICarDriverService carDriverService ; 
	
	@Autowired
	private SystemConfigFeign systemConfigFeign ;
	
//	@Resource(menuName="对账订单")
//	@RequestMapping(value=MappingUtils.SHOW_ACCOUNT_ORDER_LIST_PAGE)
//	public ModelAndView showAccountOrderListPage(OrderSearch search,String cdInfo){
//		Long cysId = CysContext.getCysID();
//		search.setCysid(cysId + "");
//		//只查询已完成的
////		search.set(4);
//		if(StrUtil.isNotBlank(cdInfo)) {
//			//List<Long> carids = carService.getCarInfoId(cdInfo);
//			//search.setCarids(carids);
//		}
////		ObjectRestResponse<PageResponse<Order>> orderResult = bizDispatchingOrderFeign.sysOrder(search);
////		PageResponse<Order> data = orderResult.getData();
////		for (Order order : data.getRecords()) {
////			ObjectRestResponse<BizDispatchingOrdercao> bizResult = bizDispatchingOrderFeign.getBizInfoByOrder(order.getOrderId());
////			BizDispatchingOrdercao biz = bizResult.getData();
////			order.setBiz(biz);
//////			Car car = carService.getById(biz.getCarId());
//////			biz.setCar(car);
////
//////			CarTypeVo carType = systemConfigFeign.getCarTypeInfo(car.getModel()).getData();
////			//car.setCarTypeName(carType.getTypeName());
////		}
////		if(data.getPages() == 0) {
////			data.setPages(1);
////		}
//		Cys cys = cysService.getCurrent();
//		CysAccount cysAccount = cysAccountService.getCurrentByCid();
//		BigDecimal cashingMoney = cysCashLogService.getCashingMoney();
//		ModelAndView m = new ModelAndView(MappingUtils.SHOW_ACCOUNT_ORDER_LIST_PAGE);
//		CysChild cysChild = cysService.getCurrentLogin() ;
//		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ; //当前登录的用户
//		m.addObject("cys", cys == null ? new Cys() : cys) ;
//		m.addObject("cysAccount", cysAccount) ;
//		m.addObject("cashingMoney", cashingMoney) ;
////		m.addObject("data", data) ;
//		m.addObject("cdInfo", cdInfo) ;
//		m.addObject("search", search) ;
// 		return m ;
//	}
//
	@Resource(menuName="充值管理")
	@RequestMapping(value=MappingUtils.SHOW_RECHARGE_MANAGER_PAGE)
	public ModelAndView showRechargeManagerPage(){
		ModelAndView m = new ModelAndView(MappingUtils.SHOW_RECHARGE_MANAGER_PAGE);
		CysChild cysChild = cysService.getCurrentLogin() ;
		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ;
		return m ;
	}
	
	@Resource(menuName="发票管理")
	@RequestMapping(value=MappingUtils.SHOW_INVOICE_MANAGER_PAGE)
	public ModelAndView showInvoiceManagerPage(){
		ModelAndView m = new ModelAndView(MappingUtils.SHOW_INVOICE_MANAGER_PAGE);
		CysChild cysChild = cysService.getCurrentLogin() ;
		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ;
		return m ;
	}
	
	@Resource(menuName="提现管理")
	@RequestMapping(value=MappingUtils.SHOW_CASH_MANAGER_PAGE)
	public ModelAndView showCashManagerPage(CysCashLogQueryVo vo) {
		cysCashLogService.getCurrentList(vo); 
		CysChild cysChild = cysService.getCurrentLogin() ;
		
		ModelAndView m = new ModelAndView(MappingUtils.SHOW_CASH_MANAGER_PAGE);
		m.addObject("data", vo) ;
		m.addObject("current", cysChild == null ? new CysChild() : cysChild) ;
		return m ;
	}
}
